package com.faithbj.process;

import com.faithbj.common.model.CheckTotal;
import com.google.common.collect.Sets;

import java.util.Set;

/**
 * User: xiongyuanwei
 * Date: 12-7-18
 * Time: 上午12:32
 */
public class ApplyIdsCondition implements GroupableCondition<CheckTotal> {

    private Set<String> applyIds = Sets.newHashSet();

    @Override
    public boolean isSatisfiedBy(CheckTotal checkTotal) {
        String applyId = checkTotal.getId();
        return applyId != null && applyIds.contains(applyId);
    }

    @Override
    public boolean isEmpty() {
        return false; // false 表示该condition默认不会被满足
    }

    public Set<String> getApplyIds() {
        return applyIds;
    }

    public void setApplyIds(Set<String> applyIds) {
        this.applyIds = applyIds;
    }

    @Override
    public Object getGroupKey(CheckTotal checkTotal) {
        return checkTotal.getId();
    }

    @Override
    public boolean isGroupKeySatisfied(CheckTotal checkTotal) {
        return isSatisfiedBy(checkTotal);
    }
}
